package com.company;

/**
 * @date : 2021-12-13 下午9:48
 * switch可以用的参数类型
 * jdk1.7之前 char byte short int  short
 * jdk1.7之后增加 Character Byte Short Integer String enum类
 */

public class P009_SwitchParam {

    public static void main(String[] args) {
        String s = null;
        Integer integer = null;
        testSwitch(integer);
        testSwitch(s);
    }

    public static void testSwitch(String t) {
        // 参数类型不能为null
        switch (t) {
            case "1":
                System.out.println(1);
                break;
            case "2":
                System.out.println(2);
                break;
            default:
                System.out.println(3);
        }
    }

    public static void testSwitch(Integer t) {
        switch (t) {
            case 1:
                System.out.println(1);
                break;
            case 2:
                System.out.println(2);
                break;
            default:
                System.out.println(3);
        }
    }
}
